<!doctype html>
<html lang="zh-CH">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<!-- <meta name="viewport" content="width=device-width, initial-scale=1"> -->
	<title>木投网--个人中心--发布现货资源</title>
	<link rel="stylesheet" href="/resource/css/mt_index.css">
	<link rel="stylesheet" href="/resource/css/mt_user.css">
	<link rel="stylesheet" href="/resource/css/mt_showBo.css">
</head>
<body>
@include("common.shop_user_head")
		<div class="user-cont left">
			<div class="user-title">发布现货资源</div>
			<div class="resource">
				<!-- 发布现货资源 -->
				<div class="popup-order">
					<div class="order-info">
						温馨提示：发布成功后，1个工作日内审核完成。
					</div>
					<form action="/user_add_now_resource" class="form" method="post">
						<div class="form-group">
							<label for="">商品标题：</label>
							<input type="text" class="form-control" placeholder="如：樟子松" name="product_name" id="product_name" onblur="check_product_name()">
							<i class="i-red">*</i>
							<span id="t_product_name">不能为空</span>
						</div>
						<div class="form-group">
							<label for="">规格：</label>
							<input type="text" class="form-control" placeholder="请填写规格" name="spec"  id="spec" onblur="check_spec()">
							<i class="i-red">*</i>
							<span id="t_spec">不能为空</span>
						</div>
						<div class="form-group">
							<label for="">产地：</label>
							<input type="text" class="form-control" placeholder="请填写场地" name="place" id="place" onblur="check_place()">
							<i class="i-red">*</i>
							<span id="t_place">不能为空</span>
						</div>
						<div class="form-group">
							<label for="">等级：</label>
							<input type="text" class="form-control" placeholder="请填写等级" name="level" id="level" onblur="check_level()">
							<i class="i-red">*</i>
							<span id="t_level">不能为空</span>
						</div>
						<div class="form-group form-two">
							<label for="">价格：</label>
							<input type="text" class="form-control" placeholder="请填写数字或面议" name="price" id="price" onblur="check_price()">
							<i class="i-red">*</i>
							<span id="t_price">不能为空</span>
						</div>
						<div class="form-group form-two">
							<label for="">单位：</label>
							<select name="unit" id="unit" class="form-control" onchange="check_unit()">
								<option value="立方米">立方米</option>
								<option value="平方米">平方米</option>
								<option value="吨">吨</option>
								<option value="张">张</option>
								<option value="公斤">公斤</option>
							</select>
							<i class="i-red">*</i>
							<span id="t_unit">不能为空</span>
						</div>
						<div class="form-group clear">
							<label for="">库存量：</label>
							<input type="text" class="form-control" placeholder="请填写真实的库存量，如5000" name="stock" onblur="check_stock()" id="stock">
							<i class="i-red">*</i>
							<span id="t_stock">不能为空</span>
						</div>
						<div class="form-group">
							<label for="">起订量：</label>
							<input type="text" class="form-control" placeholder="请填写最低的起订量，如1" name="start_num" onblur="check_start_num()" id="start_num">
							<i class="i-red">*</i>
							<span id="t_start_num">不能为空</span>
						</div>
						<div class="form-group form-two clear">
							<label for="">仓储地：</label>
							<select name="storage" id="storage" class="form-control">
								<option value="北京">北京</option>
							</select>
							<input type="text" class="form-control form-address" placeholder="详细地址" name="address"  id="address"onblur="check_address()">
							<i class="i-red">*</i>
							<span id="t_address">不能为空</span>
						</div>
						<div class="form-group clear">
							<label for="">上传图片：</label>
							<div class="form-bg">
								<div class="img"></div>
								<div class="img"></div>
								<div class="img"></div>
								<div class="file-info">最多可上传三张</div>
							</div>
							<div class="form-img"></div>
							<div class="form-file" id="file-now"></div>
						</div>
						<div class="form-group clear">
							<label for="">商品说明：</label>
							<textarea name="description" class="form-control"></textarea>
						</div>
						<div class="form-hr"></div>
						<div class="form-group form-two">
							<label for="">联系人：</label>
							<input type="text" class="form-control" placeholder="" name="contact_name" onblur="check_contact_name()" id="contact_name">
							<i class="i-red">*</i>
							<span id="t_contact_name">不能为空</span>
						</div>
						<div class="form-group form-two">
							<label for="">电话：</label>
							<input type="text" class="form-control" placeholder="" name="contact" id="contact" onblur="check_contact()">
							<i class="i-red">*</i>
							<span id="t_contact">不能为空</span>
						</div>
						<div class="form-group clear">
							<label for="">公司：</label>
							<input type="text" class="form-control" placeholder="" name="company" id="company" onblur="check_company()">
							<i class="i-red">*</i>
							<span id="t_company">不能为空</span>
						</div>
						<input type="button" class="btn-immed  J_btn" value="立即发布">
					</form>
				</div>
			</div>
		</div>
@include("common.shop_user_foot")
<div id="file_token" class="hide">{{$token}}</div>
<script src="/resource/js/jquery-1.11.3.min.js"></script>
<script src="/resource/js/mt_index.js"></script>
<script src="/resource/js/mt_showBo.js"></script>  <!-- 提示信息 -->
<script src="/resource/js/webuploader.html5only.min.js"></script>
<script src="/resource/js/diyUpload.js"></script>
<script>
	var toKen = $('#file_token').html();
	$('#file-now').diyUpload({

		success:function( data ) {
			console.log(data);
//			var imgSrc = "http://picture.mutouw.com/"+data.key;
//			var user_name = $("#username").val();
//			var phone = $("#phone").val();
//			var corporation = $("#corporation").val();
//			var address = $("#address").val();
//			$.ajax({
//				url: "/user_account_modify",
//				type: "POST",
//				data: "user_name=" + user_name +"&phone="+phone+"&corporation="+corporation+"&address="+address+'&avatar='+imgSrc,
//				success: function (msg) {
//					if(msg){
//						Showbo.Msg.alert('<img src="/resource/img/popup_success_.png" alt=""><div style="width:350px;"></div><br/>');
//						$('#dvMsgBtns input.btn').css('width','120px');
//					}
//				}
//			})
		},
		error:function( err ) {
			console.log( err );
		},
		fileNumLimit:3
	});
	$(document).delegate('.btn-immed','click',function(){
		if($(this).hasClass('J_btn')){
			$('.btn-immed').addClass('btn-black').removeClass('btn-file');
			alert("未添加图片");
		}else{
			if(!check_product_name()||!check_spec()||!check_place()||!check_level()||!check_price()||!check_unit()||!check_stock()||!check_start_num()||!check_storage()||!check_contact_name()||!check_contact()||!check_company()||!check_address()){
				alert(1)
				$('.btn-immed').addClass('btn-black').removeClass('btn-file');
			}else{
				alert(2)
				$('.btn-immed').removeClass('btn-black').addClass('btn-file');
			}
		};
		console.log(!check_product_name()||!check_spec()||!check_place()||!check_level()||!check_price()||!check_stock()||!check_start_num()||!check_storage()||!check_contact_name()||!check_contact()||!check_company()||!check_address());
	});


		function check_product_name() {
			var product_name = $('#product_name').val();
			if (product_name){
				$("#t_product_name").hide();
				$('.btn-immed').removeClass('btn-black');
				return true
			} else {
				$("#t_product_name").show();
				$('.btn-immed').addClass('btn-black');
				return false
			}
			}

	function check_spec() {
		var spec = $('#spec').val();
		if (spec){
			$("#t_spec").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_spec").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_place() {
		var place = $('#place').val();
		if (place){
			$("#t_place").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_place").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_level() {
		var level = $('#level').val();
		if (level){
			$("#t_level").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_level").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_price() {
		var price = $('#price').val();
		if (price){
			$("#t_price").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_price").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}
	function check_unit() {
		var unit = $('#unit').val();
		if (unit){
			$("#t_unit").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_unit").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_stock() {
		var stock = $('#stock').val();
		if (stock){
			$("#t_stock").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_stock").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_start_num() {
		var start_num = $('#start_num').val();
		if (start_num){
			$("#t_start_num").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_start_num").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_storage() {
		var storage = $('#storage').val();
		if (storage){
			$("#t_storage").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_storage").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_contact_name() {
		var contact_name = $('#contact_name').val();
		if (contact_name){
			$("#t_contact_name").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_contact_name").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_contact() {
		var contact = $('#contact').val();
		if (contact){
			$("#t_contact").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_contact").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_company() {
		var company = $('#company').val();
		if (company){
			$("#t_company").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_company").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}

	function check_address() {
		var address = $('#address').val();
		if (address){
			$("#t_address").hide();
			$('.btn-immed').removeClass('btn-black');
			return true
		} else {
			$("#t_address").show();
			$('.btn-immed').addClass('btn-black');
			return false
		}
	}
</script>
</body>
</html>